package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.ReceiverMessage;

public class ReceiverMessageValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return ReceiverMessage.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgReId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgTitle", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgSendUser", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgReceiverUser", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "siteId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgStatus", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgBox", "required");
	}

}
